package com.tiku.controller;

import com.tiku.common.ResultJson;
import com.tiku.controller.TO.replyCommentTO;
import com.tiku.entity.UserComment;
import com.tiku.service.UserCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 小马不会跑
 * @create 2024-09-21 20:48
 */
@RestController
@RequestMapping("/comments")
@CrossOrigin("*")
public class UserCommentController {
    @Autowired
    private UserCommentService userCommentService;

//    获取全部评论信息
    @GetMapping("/user/select/comment")
    public ResultJson getUserCommentList(Integer pageNum, String classificationType){
        return userCommentService.getUserCommentList(pageNum, classificationType);
    }

    //动态详情评论
    @GetMapping("/user/select/DynamicDetails/{id}")
    public ResultJson getSelectUserComment(@PathVariable("id") String id){
        ResultJson userCommentList = userCommentService.getSelectUserComment(id);
        return userCommentList;
    }

    @PostMapping("/user/addComment")
    public ResultJson addComment(@RequestBody UserComment userComment){
        return userCommentService.addComment(userComment);
    }

    @PostMapping("/user/replyComment")
    public ResultJson replyComment(@RequestBody replyCommentTO replyCommentTO){
        return userCommentService.replyComment(replyCommentTO);
    }

    @GetMapping("/thumbsUp/{id}")
    public ResultJson thumbsUp(@PathVariable("id") String id) {
        return userCommentService.thumbsUp(id);
    }
}
